package com.jz.community.moduleshopping.refund.adapter;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.basecomm.base.ImageBrowserActivity;
import com.jz.community.moduleshopping.R;
import com.jz.community.moduleshopping.refund.bean.RefundDetailBean;
import com.jz.community.moduleshopping.refund.ui.MultiImageView;
import com.jz.community.moduleshopping.refund.ui.RefundActivity;

import java.util.ArrayList;
import java.util.List;

public class RefundDetailAdapter extends BaseQuickAdapter<RefundDetailBean, BaseViewHolder> {


    public RefundDetailAdapter(int layoutResId, @Nullable List<RefundDetailBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RefundDetailBean item) {
        //重新申请
        TextView tv_refund_resubmission = helper.getView(R.id.tv_refund_resubmission);
        tv_refund_resubmission.setOnClickListener(v -> {
            Intent intent = new Intent(mContext, RefundActivity.class);
            intent.putExtra("orderDetailBean", item.getOrderInfo());
            mContext.startActivity(intent);
            ((Activity) mContext).finish();
        });
        TextView tv_refund_time = helper.getView(R.id.tv_refund_time);
        tv_refund_time.setText(item.getCreateDate());
        TextView tv_refund_state = helper.getView(R.id.tv_refund_state);
        tv_refund_state.setText(item.getInfo());
        TextView tv_refund_describe = helper.getView(R.id.tv_refund_describe);
        tv_refund_describe.setText(item.getRefundDescribe());
        MultiImageView rv_refund_img = helper.getView(R.id.rv_refund_img);
        rv_refund_img.setList(item.getImage());
        rv_refund_img.setOnItemClickListener((view, position) -> {
            Intent intent = new Intent(mContext, ImageBrowserActivity.class);
            intent.putStringArrayListExtra("Key_ImageList", (ArrayList<String>) item.getImage());
            intent.putExtra("Key_CurrentPosition", position);
            mContext.startActivity(intent);
        });
    }
}
